/*
 * Create a provider and monitor a particular terminal for an incoming call.
 */
public class CallCtlIncall {
	static String[] mypro;

	public static final void main(String args[]) {

		/*
		 * Create a provider by first obtaining the default implementation of
		 * JTAPI and then the default provider of that implementation.
		 */
		Provider myprovider = null;
		try {
			JtapiPeer peer = JtapiPeerFactory
					.getJtapiPeer("net.xtapi.XJtapiPeer");
			myprovider = peer.getProvider("MSTAPI");
			mypro = peer.getServices();
		} catch (Exception excp) {
			System.out.println("Can't get Provider: " + excp.toString());
			System.out.println(mypro);
			System.exit(0);
		}

		/*
		 * Get the terminal we wish to monitor and add a call observer to that
		 * Terminal. This will place a call observer on all call which come to
		 * that terminal. We are assuming that Terminals are named after some
		 * primary telephone number on them.
		 */
		try {
			Terminal terminal = myprovider.getTerminal("2180916");
			terminal.addCallObserver(new MyCallCtlInCallObserver());
		} catch (Exception excp) {
			System.out.println("Can't get Terminal: " + excp.toString());
			System.exit(0);
		}
	}
}